package com.module.hq.engine;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;

import com.dalonedrau.jogl.engine.GameDrawable;
import com.dalonedrau.jogl.engine.GlobalConsts;
import com.dalonedrau.jogl.engine.Interface;
import com.dalonedrau.jogl.engine.ProjectConstants;
import com.dalonedrau.jogl.opengl.ui.view.LoadingView;
import com.dalonedrau.pool.PooledStringBuilder;
import com.dalonedrau.pool.StringBuilderPool;
import com.module.hq.bus.globals.HQGlobals;
import com.module.hq.view.CharacterChooserView;
import com.module.hq.view.DungeonScreenView;
import com.module.hq.view.DungeonSplashView;
import com.module.hq.view.IntroView;

/**
 * Game constants.
 * @author Donald
 */
public final class HQConstants extends ProjectConstants implements HQGlobals {
	/** flag indicating the project has been initialized. */
	private boolean	initialized	= false;
	/** Hidden constructor. */
	public HQConstants() {
		super.setInstance(this);
		new HQInteractive();
		HQController.getInstance();
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void assignViews() {
		if (!initialized) {
			Interface.getInstance().setView(HQGlobals.VIEW_00_INTRO,
					new IntroView());
			Interface.getInstance().setView(HQGlobals.VIEW_01_LOADING,
					LoadingView.getInstance());
			Interface.getInstance().setView(
					HQGlobals.VIEW_02_CHARACTER_CHOOSER,
					CharacterChooserView.getInstance());
			Interface.getInstance().setView(HQGlobals.VIEW_03_DUNGEON_SPLASH,
					DungeonSplashView.getInstance());
			Interface.getInstance().setView(HQGlobals.VIEW_04_DUNGEON_SCREEN,
					DungeonScreenView.getInstance());
			initialized = true;
		}
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public Color getDefaultFontColor() {
		return HQGlobals.HQ_MONO_FONT_COLOR;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getFontH1() {
		return "fairlight_12";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getFontH2() {
		return "fairlight_10";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getFontNormal() {
		return "fairlight_12";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getFontTitle() {
		return "fairlight_14";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public Color getInactiveFontColor() {
		return HQGlobals.HQ_MONO_INACTIVE_COLOR;
	}
	@Override
	public String getMapFilePath() {
		return "com/module/hq/dat/maps";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int getNumGameFonts() {
		return GlobalConsts.INT_006;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getScrollBarDownArrowImage() {
		return "scroll_down";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getScrollBarUpArrowImage() {
		return "scroll_up";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getTextFileListing() {
		return "listing.txt";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getTextFilePath() {
		return "com/cob/dat/text";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getTooltipBorderClass() {
		return "com.module.hq.ui.mono.borders.HQMonoTooltipBorder";
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public Color getTooltipFontColor() {
		return HQGlobals.HQ_MONO_FONT_COLOR;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String[] getVXStyleDialogBorderImages() {
		return HQGlobals.HQ_MONO_VX_BORDER;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public float[] getVXStyleDialogGradientBottom() {
		return HQGlobals.COL_HQ_MONO_VX_DLG_BOTTOM;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public float[] getVXStyleDialogGradientTop() {
		return HQGlobals.COL_HQ_MONO_VX_DLG_TOP;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int[] getVXStyleDialogInsets() {
		return new int[] { GlobalConsts.INT_007, GlobalConsts.INT_007,
				GlobalConsts.INT_007, GlobalConsts.INT_007 };
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int getVXStyleDialogXOffset() {
		return 1;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int getVXStyleDialogYOffset() {
		return 1;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String[] getVXStyleSpeechBorderImages() {
		return getVXStyleDialogBorderImages();
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public float[] getVXStyleSpeechGradientBottom() {
		return HQGlobals.COL_HQ_MONO_VX_SPEECH_BOTTOM;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public float[] getVXStyleSpeechGradientTop() {
		return HQGlobals.COL_HQ_MONO_VX_SPEECH_TOP;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int[] getVXStyleSpeechInsets() {
		return getVXStyleDialogInsets();
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int getVXStyleSpeechXOffset() {
		return 1;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int getVXStyleSpeechYOffset() {
		return 1;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void initCursors() {
		Toolkit toolkit = Toolkit.getDefaultToolkit();
		// default cursor
		Image cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/default_cursor.gif");
		Point cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(Cursor.DEFAULT_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						Cursor.getDefaultCursor().getName()
						));
		// hand cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/hand_cursor.gif");
		cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(Cursor.HAND_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
								.getName()
						));
		// wait cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/wait_cursor.gif");
		cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(Cursor.WAIT_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)
								.getName()
						));
		// pan east cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_e.gif");
		cursorHotSpot = new Point(16, 0);
		GameDrawable.setCursor(GameDrawable.PAN_EAST_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan east"
						));
		// pan north cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_n.gif");
		cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(GameDrawable.PAN_NORTH_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan north"
						));
		// pan northeast cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_nne.gif");
		cursorHotSpot = new Point(16, 0);
		GameDrawable.setCursor(GameDrawable.PAN_NORTHEAST_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan northeast"
						));
		// pan northwest cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_nnw.gif");
		cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(GameDrawable.PAN_NORTHWEST_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan northwest"
						));
		// pan south cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_s.gif");
		cursorHotSpot = new Point(0, 16);
		GameDrawable.setCursor(GameDrawable.PAN_SOUTH_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan south"
						));
		// pan southeast cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_sse.gif");
		cursorHotSpot = new Point(16, 16);
		GameDrawable.setCursor(GameDrawable.PAN_SOUTHEAST_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan southeast"
						));
		// pan southwest cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_ssw.gif");
		cursorHotSpot = new Point(0, 16);
		GameDrawable.setCursor(GameDrawable.PAN_SOUTHWEST_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan southwest"
						));
		// pan west cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/pan_w.gif");
		cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(GameDrawable.PAN_WEST_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"pan west"
						));
		// move cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/move_cursor.gif");
		cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(GameDrawable.MOVE_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"move"
						));
		// attack cursor
		cursorImage = HQController.getInstance().loadImage(
				"com/module/hq/dat/attack_cursor.gif");
		cursorHotSpot = new Point(0, 0);
		GameDrawable.setCursor(GameDrawable.ATTACK_CURSOR,
				toolkit.createCustomCursor(
						cursorImage,
						cursorHotSpot,
						"attack"
						));
	}
	@Override
	public void initGameMaps() throws Exception {
		PooledStringBuilder sb0 =
				StringBuilderPool.getInstance().getStringBuilder();
		PooledStringBuilder sb1 =
				StringBuilderPool.getInstance().getStringBuilder();
		for (int i = 0; i < 1; i++) {
			sb0.append("maze_");
			sb1.append("map");
			if (i < 10) {
				sb0.append("0");
			}
			sb0.append(i);
			sb0.append(".xml");
			sb1.append(i);
			HQScript.getInstance().setGlobalVariable(
					sb1.toString(), sb0.toString());
			sb0.setLength(0);
			sb1.setLength(0);
		}
		sb0.returnToPool();
		sb1.returnToPool();
	}
}
